app.controller('yesOrNoCtrl',['$scope','$location','$http','homeService',function($scope,$location,$http,homeService) {

    if(localStorage.getItem('nodeName')==null){
        $scope.bmName = localStorage.getItem('morengongsi');
        //localStorage.removeItem('morengongsi')
    }else{
        $scope.bmName = localStorage.getItem('nodeName');
    }
    localStorage.removeItem('nodeName')
    console.log(localStorage.getItem('nodeName'));
    var btn = document.getElementById('showModel');
    var close = document.getElementsByClassName('close')[0];
    var cancel = document.getElementById('cancel');
    var modal = document.getElementById('modal');
    var content = document.getElementsByClassName('modal-content')[0];
    btn.addEventListener('click', function(){
        modal.style.display = "block";
    });
    close.addEventListener('click', function(){
        modal.style.display = "none";
    });
    cancel.addEventListener('click', function(){
        modal.style.display = "none";
    });
    modal.addEventListener('click', function (){
        modal.style.display = "none";
    });
    modal.addEventListener('click', function (){
        modal.style.display = "none";
    });
    content.addEventListener('click', function(){
        modal.style.display = "block";
    });
    console.log($location.path())

    $scope.xzbm = function () {
        var token = localStorage.getItem('token');
        mui.showLoading('正在加载','div');
        $http({
            method: "POST",
            url: mainUrl+'/om/om-orgnization!findIndexProcedurePrivilege4App.action',
            params: {
                'Authorization': token,
                "name":"qm.addDefaultCompany",
                "value":"1"
                /*'qm.flag' : 1*/
            }
        }).then(
            function(data, status, headers, config){
                console.log(data)
                $scope.item = data.data.items;
                mui.hideLoading();
                // document.getElementsByClassName('mui-switch-blue').addEventListener
            },function(data, status, headers, config){

            }
        );
    }
    $scope.setValue = function ($event) {
        var token = localStorage.getItem('token');
console.log($event)
        $http({
                method: "POST",
                url: mainUrl+'/md/md-pdata!findNow4App.action',
                params: {
                    'Authorization': token ,
                    'qm.company' : $event.nodeId
                }
            }).then(
                function(data, status, headers, config){
                    console.log(data);
                    /*$scope.content=data.data.items[0].content;*/
                    /*for(var i=0;i<data.data.items.length;i++){
                        $scope.content+=data.data.items[i].title;
                    }*/
                    homeService.setData(JSON.stringify(data));
                    localStorage.setItem('nodeName',$event.nodeName);

                    console.log()
                    location.reload();
                },function(data, status, headers, config){

                })

    }

}])